package u.hnx.admin.system.service.impl;

import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import u.hnx.admin.dto.user.UserDTO;
import u.hnx.admin.exception.sys.UserBlankException;
import u.hnx.admin.system.dao.user.UserDAO;

import java.util.Optional;

@Service
@RequiredArgsConstructor
public class UserDetailsServiceImpl implements UserDetailsService {
    private final UserDAO userDAO;
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        UserDTO userDTO = userDAO.getUserByName(username);
        Optional.ofNullable(userDTO).orElseThrow(()->new UserBlankException("用户名不存在"));
        return null;
    }
}
